<script>
export default {
  name: "setSet",
  data() {
    return { loginName: "登录" };
  },
  methods: {
    init() {
      if (!this.$store.getters.getUserInfo.token) {
        this.loginName = "登录";
      } else {
        this.loginName = "退出登录";
      }
    },
    goLogin() {
      if (!this.$store.getters.getUserInfo.token) {
        this.$router.push({ name: "login" });
      } else {
        this.logout();
        return;
      }
    },
    logout() {
      localStorage.removeItem("userInfo");
      this.$router.push({ name: "my" });
      window.location.reload();
    },
  },
  mounted() {
    this.init();
  },
};
</script>

<template>
  <div style="padding-top: 8px">
    <van-cell title="111" is-link />
    <van-cell title="版本" style="margin-top: 8px" value="1.0.0" is-link />
    <van-cell style="margin-top: 12px">
      <template #default>
        <div
          @click="goLogin"
          style="
            color: #fa436a;
            display: flex;
            justify-content: center;
            align-items: center;
          "
        >
          {{ loginName }}
        </div>
      </template>
    </van-cell>
  </div>
</template>

<style scoped></style>
